package com.study.hystrix.service;

import org.springframework.stereotype.Repository;

import java.util.*;

/**
 * @author: chenhs
 * @date: Created in 9:54 2019/12/14
 **/
@Repository
public class QueryServiceRemoteCall {


    public Map<String, Object> queryCommodity(String code) {
        Map<String, Object> map = new HashMap<>();
        map.put("code", code);
        map.put("phone", "huawei");
        map.put("price", 4000);
        map.put("isOk", true);
        map.put("commodityId", new Random().nextInt(10000));

        return map;
    }


    public List<Map<String, Object>> queryCommodityBatch(List<String> codes) {
        List<Map<String, Object>> results = new ArrayList<>();

        for (int i = 0; i < codes.size(); i++) {
            Map<String, Object> map = new HashMap<>();
            map.put("code", codes.get(i));
            map.put("phone", "huawei");
            map.put("price", 4000);
            map.put("isOk", true);
            map.put("commodityId", new Random().nextInt(100000));
            results.add(map);
        }

        return results;
    }


}
